<template>

    标题:<input type="text" v-model="Sousuo.Mname">

    适用门店： <select v-model="Sousuo.Tid" >
                            <option :value="-1">请选择</option>
                            <option  v-for="item in FanTian" :value="item.tid">{{ item.tname }}</option>
                        </select>

                        <button class="btn btn-success" @click="Show"> 搜索</button>
                        <button @click="IsDel" class="btn btn-success">批量删除</button>
    <table class=" table table-bordered">

   
        <thead>

            <tr>
                <input type="checkbox" v-model="Quanxuan1" @change="QuanXuan">
                <th>卷类型 </th>
                <th>标题 </th>
                <th>副标题 </th>
                <th>代金卷图片 </th>
                <th>每人限领 </th>
                <th>使用条件 </th>
                <th>减免 </th>
                <th>开始时间 </th>
                <th>结束时间 </th>
                <th>适用业务 </th>
                <th>使用须知 </th>
 
                <th>营销手机号 </th>
                <th>适用门店 </th>
                <th>操作 </th>

            </tr>





        </thead>

        <tbody v-for="item in bb">


            <tr>

                <input type="checkbox" :checked="XuanZe" :value="item.mid" v-model="addries" >
                <th>{{item.juanType }} </th>
                <th>{{ item.mname }} </th>
                <th>{{ item.mtname }} </th>
                <th><img :src="item.mimg" style="width: 100px; height: 100px;"> </th>
                <th>{{ item.mnum}} </th>
                <th>{{ item. tiaoJian}} </th>
                <th>{{ item. jianMian}} </th>
                <th>{{ item. ctime}} </th>
                <th>{{ item. stime}} </th>
                <th>{{ item. yeWu}} </th>
                <th>{{ item. xuZhi}} </th>
          
                <th> {{ item. mPhone}}</th>
                <th>{{ item. tname}} </th>
                <th><a href="#"  @click="Xg(item.mid)" class="btn btn-success">修改</a></th>



            </tr>




        </tbody>
    </table>

    当前<span style="color: red;">{{FenYe.s  }}</span>页
    总共<span style="color: red;">{{FenYe.Zy }}</span>页
    总共<span style="color: red;">{{FenYe.Count }}</span>条

    <button @click="Fenye1('S')">首页</button>
    <button @click="Fenye1('E')">上一页</button>
    <button @click="Fenye1('F')">下一页</button>
    <button @click="Fenye1('M')">尾页</button>



</template>


<script setup lang="ts">




import { onMounted, ref } from 'vue';

import axios from 'axios';
const aa=ref([{


}])

const Sousuo=ref({

    Mname:"",
    Tid:-1,
  

})
  const FenYe=ref({

    s:1,
    m:3,
    Count:0,
    Zy:0,

  })
onMounted(()=>{
    FanTian1();
    Show();
})

const Fenye1=(chool:string)=>{


    switch(chool){
            case'E':

            if(FenYe.value.s>1)
            {
                FenYe.value.s-=1
                Show();


            }
            else
            {
                alert('页码不能小于1')
                return ;
            }
                break;

            case'F':
           

        if(FenYe.value.s<FenYe.value.Zy)
            {
    FenYe.value.s+=1
    Show();

            }
    else
        {
    alert('页码不能大于总页数')
    return ;
        }
    break;

    case'S':

       FenYe.value.s=1
       Show();
    break;

    
    case'M':

       FenYe.value.s=FenYe.value.Zy
       Show();
    break;

    }

    



}

const bb:any=ref([{

        "mid": 27,
      "mname": "代金卷",
      "mtname": "超级代金卷",
      "mimg": "https://localhost:7039/Images/6.jpg",
      "mnum": 12,
      "tiaoJian": 500,
      "jianMian": 10,
      "ctime": "2024-12-06T00:00:00",
      "stime": "2024-12-14T00:00:00",
      "yeWu": "订房,商城",
      "xuZhi": "必须在12.14之前用\n",
      "juanType": "代金卷",
      "mPhone": "19563365890",
      "tid": 1,
      "tname": "山东菏泽"



}])


const Show=()=>{

   
axios.get('https://localhost:7039/api/User/ShowMark',{params:{

    Mname:Sousuo.value.Mname,
    Tid:Sousuo.value.Tid,
    s:FenYe.value.s,
    m:FenYe.value.m


}}).then(res=>{

    FenYe.value.Count=res.data.count,
    FenYe.value.Zy=res.data.zy,

        bb.value=res.data.data

})

}


    const Quanxuan1=ref(false);
    const XuanZe=ref(false);
    const addries=ref([])
const QuanXuan =()=>{
 
        if(Quanxuan1.value==true)
        {
            XuanZe.value=true;

                  
               addries.value= bb.value.map((item:any)=>{

                return item.mid;
               })
              

        }
        else
        {
            XuanZe.value=false;
        }



}




const FanTian=ref([{

"tid":0 ,
"tname": ""

}])
const  FanTian1 =()=>{

     
    axios.get('https://localhost:7039/api/User/ShowType').then(res=>{

        FanTian.value=res.data

})

}


const IsDel=()=>{


    if(!confirm('确定删除吗？'))
{
    return ;
}
    axios.delete('https://localhost:7039/api/User/IsDel',{params:{
            id:addries.value.toString()

    }}).then(res=>{

        if(res.data>0)
    {
        alert('删除成功')
        Show();
    }
    else
    {
        alert('删除失败')
    }
    })

}


import { useRouter,createRouter } from 'vue-router';
const router= useRouter()
const Xg=(id:number)=>{


router.push({

        name:'XgMark',
        params:{

            id:id,
        }


})

}


</script>